Skip to content

fix(Assembler): say what to do about an ambiguous merge - #2222

Merged
DerManoMann merged 1 commit into
zircote:masterfrom
DerManoMann:fix/ambiguous-merge-hint
Oct 1, 2026
Merged

DerManoMann merged 1 commit into
zircote:masterfrom
DerManoMann:fix/ambiguous-merge-hint

Conversation

@DerManoMann

Copy link
Copy Markdown
Collaborator

Overview

Ambiguous merge names the problem and stops there. An author who stacks a #[Header] beside two #[Response] attributes is told their attribute matches multiple siblings on the same target — accurate, and it leaves them nowhere. There are two ways out and neither is obvious from the wording: nest the attribute in the response it belongs to, or give it a component and reference it from each.

The message now says so.

Ambiguous merge: OpenApi\Spec\Header matches multiple siblings on the same target.
Nest it explicitly in the one it belongs to, or give it a `component` and reference it from each.

Changes

  • Utils\AttributeFactory carries the two resolutions in the exception it already throws, at the source location it already reports

Notes

Found while converting a real codebase from OpenApi\Attributes to OpenApi\Spec, where this is the single reason the converted project loses most of its paths — it fires ten times across twenty-two annotated files, because classic resolved the same code by writing the header into every sibling response and spec rightly refuses to guess at that.

It is not a migration-specific problem, which is why the hint belongs here rather than in a migration guide: the same message reaches anyone writing spec attributes by hand. docs/guide/spec-attributes.md already documents the equivalent Response/MediaType ambiguity.

AttributeFactoryTest matches the message by pattern, so it is unchanged and still passing.

The message named the problem and stopped there. An author who stacks a header
beside two responses is told their attribute matches multiple siblings, which
is accurate and leaves them nowhere: the resolutions are to nest it in the one
it belongs to, or to give it a `component` and reference it from each, and
neither is obvious from the wording.

Found migrating a real codebase, where this is the single reason a converted
project loses most of its paths, and where it fires ten times in twenty-two
files. It is not a migration-specific problem though -- the same message
reaches anyone writing spec attributes by hand -- so the hint belongs in the
diagnostic rather than in a migration guide.

`AttributeFactoryTest` matches the message by pattern, so it still holds.
@DerManoMann
DerManoMann merged commit a43bda3 into zircote:master Oct 1, 2026
19 checks passed
@DerManoMann
DerManoMann deleted the fix/ambiguous-merge-hint branch October 1, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant